var e = require("../../../../@babel/runtime/helpers/createForOfIteratorHelper"), t = require("../../../../@babel/runtime/helpers/slicedToArray"), r = require("../../../../common/vendor.js"), i = {
    components: {
        TableCheckbox: function() {
            return "./components/table-checkbox.js";
        },
        TableSummary: function() {
            return "./components/table-summary.js";
        },
        TableSideSummary: function() {
            return "./components/table-side-summary.js";
        },
        TableH5Summary: function() {
            return "./components/table-h5-summary.js";
        },
        ZbLoadMore: function() {
            return "./components/zb-load-more.js";
        }
    },
    props: {
        highlight: {
            type: Boolean,
            default: !1
        },
        itemDate: {
            type: Object,
            default: function() {}
        },
        columns: {
            type: Array,
            default: function() {
                return [];
            }
        },
        showSummary: {
            type: Boolean,
            default: !1
        },
        isShowLoadMore: {
            type: Boolean,
            default: !1
        },
        data: {
            type: Array,
            default: function() {
                return [];
            }
        },
        sumText: {
            type: String,
            default: "合计"
        },
        showHeader: {
            type: Boolean,
            default: !0
        },
        border: {
            type: Boolean,
            default: !1
        },
        stripe: {
            type: Boolean,
            default: !0
        },
        fit: {
            type: Boolean,
            default: !1
        },
        rowKey: [ String, Function ],
        summaryMethod: Function,
        pullUpLoading: Function,
        formatter: Function,
        cellStyle: Function,
        cellHeaderStyle: Function,
        permissionBtn: Function
    },
    computed: {
        loadMoreHeight: function() {
            return this.isLoadMore ? 40 : 0;
        },
        fixedLeftColumns: function() {
            for (var e = [], t = 0; t < this.columns.length; t++) {
                var r = this.columns[t];
                if (!r.fixed) break;
                e.push(r);
            }
            return e;
        },
        imgs: function() {
            return function(e) {
                return "string" == typeof e ? [ e ] : e;
            };
        },
        itemfilters: function() {
            return function(e, t) {
                return null == e[t.name] ? t.emptyString : e[t.name];
            };
        },
        scrollbarSize: function() {
            return 0;
        },
        isFixedLeft: function() {
            return !!this.columns.length && (!!this.data.length && !!t(this.columns, 1)[0].fixed);
        },
        transColumns: function() {
            var e = this;
            this.fit && this.columns.forEach(function(t) {
                if ("operation" === t.type && t.renders) {
                    var r = "";
                    t.renders.map(function(e) {
                        r += e.name;
                    }), t.width = e.getTextWidth(r) + 40 * t.renders.length;
                } else if ("img" === t.type) ; else if ("selection" === t.type) ; else {
                    var i = [ e.getTextWidth(t.label) ];
                    e.data.forEach(function(r) {
                        var n = r[t.name] + "";
                        if ("undefined" === n) i.push(30); else {
                            var o = e.getTextWidth(n);
                            i.push(o);
                        }
                    }), t.width = Math.max.apply(Math, i) + 20;
                }
            });
            var t = 0;
            return this.columns.forEach(function(r, i) {
                if ("operation" === r.type && r.renders && !r.width) {
                    var n = "";
                    r.renders.map(function(e) {
                        n += e.name;
                    }), r.width = e.getTextWidth(n) + 40 * r.renders.length;
                }
                if ("img" === r.type && !r.width) {
                    var o = [], l = e.getTextWidth(r.label);
                    e.data.forEach(function(e) {
                        if (e[r.name]) {
                            var t = "string" == typeof e[r.name] ? [ e[r.name] ] : e[r.name];
                            o.push(t.length);
                        }
                        r.width = 40 * Math.max.apply(Math, o) + l;
                    });
                }
                r.fixed && (0 === i ? (r.left = 0, t += r.width) : (r.left = t, t += r.width)), 
                r.emptyString = r.emptyString || "--";
            }), this.columns;
        },
        transData: function() {
            var e = this, t = this.columns.some(function(e) {
                return "selection" === e.type;
            });
            if (this.data.forEach(function(r, i) {
                t && r.checked && (e.selectArr.length || e.selectArr.push(r)), e.rowKey ? "function" == typeof e.rowKey ? r.key = Object.freeze(e.rowKey(r)) || Date.now() : r.key = Object.freeze(r[e.rowKey]) || Date.now() : r.key = i;
            }), t) if (this.data.length) {
                var r = this.data.filter(function(e) {
                    return e.checked;
                }).length;
                r ? r === this.data.length ? this.checkedAll = !0 : this.indeterminate = !0 : (this.checkedAll = !1, 
                this.indeterminate = !1, this.selectArr = []);
            } else this.checkedAll = !1, this.indeterminate = !1, this.selectArr = [];
            return this.data;
        },
        isHighlight: function() {
            var e = this;
            return function(t, r) {
                return e.rowKey ? t.key === e.currentRow.key : r === e.currentRowIndex;
            };
        },
        getHeaderCellStyle: function() {
            var e = this;
            return function(t, r, i) {
                var n = e.cellHeaderStyle;
                return "function" == typeof n ? n({
                    column: t,
                    columnIndex: r
                }) : {};
            };
        },
        getCellStyle: function() {
            var e = this;
            return function(t, r, i, n) {
                var o = e.cellStyle;
                return "function" == typeof o ? o({
                    row: t,
                    column: r,
                    rowIndex: i,
                    columnIndex: n
                }) : {};
            };
        }
    },
    data: function() {
        return {
            button: [],
            alipayScrollTop: 0,
            alipayScrollOldTop: 0,
            alipayFlag: !1,
            bodyTableLeft: 0,
            headerTableLeft: 0,
            lastScrollLeft: 0,
            isLoadMore: !1,
            headerFooterTableLeft: 0,
            leftFiexScrollTop: 0,
            bodyScrollTop: 0,
            currentDriver: null,
            currentDriver1: null,
            bodyTime: null,
            currentRowIndex: null,
            currentRow: {},
            bodyTime1: null,
            headerTime: null,
            debounceTime: null,
            operation: {},
            completedFlag: !1,
            selectArr: [],
            indeterminate: !1,
            checkedAll: !1,
            completeLoading: !1,
            aliTime: null
        };
    },
    created: function() {},
    mounted: function() {},
    beforeDestroy: function() {
        this.aliTime && clearTimeout(this.aliTime), this.debounceTime && clearTimeout(this.debounceTime), 
        this.bodyTime1 && clearTimeout(this.bodyTime1), this.bodyTime && clearTimeout(this.bodyTime), 
        this.selectArr = [], this.indeterminate = !1, this.checkedAll = !1;
    },
    methods: {
        clearSelection: function() {
            this.transData.forEach(function(e) {
                e.checked = !1;
            }), this.selectArr = [], this.indeterminate = !1, this.checkedAll = !1;
        },
        formatterAction: function(e, t, r, i) {
            return t.formatter && "function" == typeof this.formatter ? this.formatter(e, t, r, i) : null == e[t.name] || "" === e[t.name] ? t.emptyString : e[t.name];
        },
        permission: function(e, t, r) {
            return this.permissionBtn && "function" == typeof this.permissionBtn ? this.permissionBtn(e, t, r) : t;
        },
        pullUpCompleteLoading: function(e) {
            this.isLoadMore = !1, "ok" === e && (this.completeLoading = !0);
        },
        scrollAlipay: function(e) {
            var t = this;
            this.alipayScrollOldTop || (this.alipayScrollOldTop = e.detail.scrollTop), this.aliTime && clearTimeout(this.aliTime), 
            this.aliTime = setTimeout(function() {
                t.alipayFlag && e.detail.scrollTop > t.alipayScrollOldTop && t.pullLoad(), t.alipayFlag = !1, 
                t.alipayScrollOldTop = null;
            }, 500);
        },
        pullLoad: function() {
            if (this.isShowLoadMore) {
                this.isLoadMore = !0, this.$emit("pullUpLoading");
                var e = this;
                this.pullUpLoading && this.pullUpLoading.call(this.$parent.$parent, function(t) {
                    e.isLoadMore = !1, "ok" === t && (e.completeLoading = !0);
                });
            }
        },
        scrolltolower: function(e) {
            this.alipayFlag = !0, "bottom" === e.detail.direction && this.pullLoad();
        },
        previewImage: function(e, t, i) {
            var n = "string" == typeof t ? [ t ] : t;
            r.index.previewImage({
                current: i,
                urls: n
            });
        },
        resetHighlight: function() {
            this.currentRowIndex = null, this.currentRow = {};
        },
        cellClick: function(e, t, r) {
            this.$emit("cellClick", e, t, r);
        },
        rowClick: function(e, t) {
            this.highlight && (this.currentRowIndex = t, this.currentRow = e, this.$emit("currentChange", e, t)), 
            this.$emit("rowClick", e, t);
        },
        checkboxSelectedAll: function(e) {
            var t = this;
            this.indeterminate = !1, e.checked ? (this.selectArr = [], this.checkedAll = !0, 
            this.data.forEach(function(e) {
                e.checked = !0, t.selectArr.push(e);
            })) : (this.checkedAll = !1, this.data.forEach(function(e) {
                t.$set(e, "checked", !1);
            }), this.selectArr = []), this.$forceUpdate(), this.$emit("toggleAllSelection", e.checked, this.selectArr);
        },
        checkboxSelected: function(e, t) {
            this.data.forEach(function(t) {
                t.key === e.data.key && (t.checked = e.checked);
            }), t.checked = e.checked, e.data.checked = e.checked, e.checked ? this.selectArr.push(e.data) : this.selectArr = this.selectArr.filter(function(t) {
                return t.key !== e.data.key;
            }), this.selectArr.length === this.transData.length ? (this.indeterminate = !1, 
            this.checkedAll = !0) : (this.indeterminate = !0, this.checkedAll = !1), this.selectArr.length || (this.checkedAll = !1, 
            this.indeterminate = !1), this.$forceUpdate(), this.$emit("toggleRowSelection", e.checked, this.selectArr);
        },
        itemFilter: function(e, t) {
            if (t.filters && t.name) {
                var r = e[t.name];
                return t.filters[r] || "";
            }
            return e[t.name] || t.emptyString;
        },
        getTextWidth: function(t) {
            if (t.length < 3) return 40;
            var r, i = /^[0-9]+.?[0-9]*$/, n = 0, o = e(t);
            try {
                for (o.s(); !(r = o.n()).done; ) {
                    var l = r.value;
                    l >= "A" && l <= "Z" || l >= "a" && l <= "z" ? n += 10 : l >= "一" && l <= "龥" ? n += 15 : i.test(l) ? n += 9 : n += 7;
                }
            } catch (e) {
                e = VM2_INTERNAL_STATE_DO_NOT_USE_OR_PROGRAM_WILL_FAIL.handleException(e);
                o.e(e);
            } finally {
                o.f();
            }
            return n;
        },
        width: function(e) {
            return "".concat(e.width ? e.width : "100", "px");
        },
        showStripe: function(e) {
            if (!this.currentDriver) return this.stripe ? e % 2 != 0 ? "odd" : "even" : "";
        },
        checkNumber: function(e) {
            return !!/^[0-9]+.?[0-9]*$/.test(e);
        },
        isDate: function(e) {
            return !(!isNaN(e) || isNaN(Date.parse(e)));
        },
        sortAction: function(e, t) {
            if (!e.sorter) return !1;
            this.$set(e, "sorterMode", "_asc" === e.sorterMode ? "_desc" : "_asc"), "custom" === e.sorter ? this.$emit("sort-change", e, e.sorterMode.replace("_", ""), t) : this.sortData(e), 
            this.$forceUpdate();
        },
        sortData: function(e) {
            var t = this, r = e.name;
            "_asc" === e.sorterMode ? this.data.sort(function(e, i) {
                return t.checkNumber(e[r]) ? e[r] - i[r] : t.isDate(e[r]) ? new Date(e[r]).getTime() - new Date(i[r]).getTime() : void 0;
            }) : this.data.sort(function(e, i) {
                if (t.checkNumber(e[r])) return i[r] - e[r];
                if (t.isDate(e[r])) {
                    var n = new Date(e[r]).getTime();
                    return new Date(i[r]).getTime() - n;
                }
            });
        },
        throttle: function(e) {
            var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 60, r = null;
            return function() {
                for (var i = arguments.length, n = new Array(i), o = 0; o < i; o++) n[o] = arguments[o];
                r || (r = setTimeout(function() {
                    e.apply(void 0, n), r = null;
                }, t));
            };
        },
        debounce: function(e) {
            var t = this, r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 1e3;
            return function() {
                for (var i = arguments.length, n = new Array(i), o = 0; o < i; o++) n[o] = arguments[o];
                t.debounceTime && clearTimeout(t.debounceTime), t.debounceTime = setTimeout(function() {
                    e.apply(void 0, n);
                }, r);
            };
        },
        handleBodyScroll: function(e) {
            var t = this;
            this.currentDriver && this.currentDriver !== e.currentTarget.id || (this.currentDriver = e.currentTarget.id, 
            this.headerTableLeft = e.detail.scrollLeft, this.headerFooterTableLeft = e.detail.scrollLeft, 
            this.leftFiexScrollTop = e.detail.scrollTop, this.bodyTime && clearTimeout(this.bodyTime), 
            this.bodyTime = setTimeout(function() {
                t.currentDriver = null;
            }, 200));
        },
        leftFixedScrollAction: function(e) {
            var t = this;
            this.currentDriver && this.currentDriver !== e.currentTarget.id || (this.currentDriver = e.currentTarget.id, 
            this.bodyScrollTop = e.detail.scrollTop, this.bodyTime && clearTimeout(this.bodyTime), 
            this.bodyTime = setTimeout(function() {
                t.currentDriver = null;
            }, 200));
        },
        scrollToLeft: function(e) {
            var t = this;
            this.currentDriver1 && this.currentDriver1 !== e.currentTarget.id || (this.currentDriver1 = e.currentTarget.id, 
            "left" === e.detail.direction && this.headerTableLeft < 10 ? this.headerTableLeft = 0 : "top" === e.detail.direction && this.leftFiexScrollTop < 10 && (this.leftFiexScrollTop = 0), 
            this.bodyTime && clearTimeout(this.bodyTime), this.bodyTime = setTimeout(function() {
                t.currentDriver1 = null;
            }, 200));
        },
        scrollToFixedLeft: function(e) {
            var t = this;
            this.currentDriver1 && this.currentDriver1 !== e.currentTarget.id || (this.currentDriver1 = e.currentTarget.id, 
            "top" === e.detail.direction && this.bodyScrollTop < 10 && (this.bodyScrollTop = 0), 
            this.bodyTime && clearTimeout(this.bodyTime), this.bodyTime = setTimeout(function() {
                t.currentDriver1 = null;
            }, 200));
        },
        handleTableScrollLeft: function(e, t) {
            var r = this;
            this.currentDriver && this.currentDriver !== e.currentTarget.id || (this.currentDriver = e.currentTarget.id, 
            this.bodyTableLeft = e.detail.scrollLeft, this.headerFooterTableLeft = e.detail.scrollLeft, 
            this.bodyTime && clearTimeout(this.bodyTime), this.bodyTime = setTimeout(function() {
                r.currentDriver = null;
            }, 200));
        },
        handleFooterTableScrollLeft: function(e) {
            var t = this;
            this.currentDriver && this.currentDriver !== e.currentTarget.id || (this.currentDriver = e.currentTarget.id, 
            this.bodyTableLeft = e.detail.scrollLeft, this.headerTableLeft = e.detail.scrollLeft, 
            this.bodyTime && clearTimeout(this.bodyTime), this.bodyTime = setTimeout(function() {
                t.currentDriver = null;
            }, 200));
        }
    }
};

Array || (r.resolveComponent("tableCheckbox") + r.resolveComponent("table-summary") + r.resolveComponent("zb-load-more"))();

var n = r._export_sfc(i, [ [ "render", function(e, t, i, n, o, l) {
    return r.e({
        a: i.showHeader
    }, i.showHeader ? {
        b: r.f(l.transColumns, function(e, t, i) {
            return r.e({
                a: "selection" === e.type
            }, "selection" === e.type ? {
                b: r.o(l.checkboxSelectedAll, t),
                c: "6252a029-0-" + i,
                d: r.p({
                    indeterminate: o.indeterminate,
                    checked: o.checkedAll
                })
            } : r.e({
                e: r.t(e.label || ""),
                f: e.sorter
            }, e.sorter ? {
                g: r.n("_asc" === e.sorterMode && "sorting".concat(e.sorterMode || "")),
                h: r.n("_desc" === e.sorterMode && "sorting".concat(e.sorterMode || ""))
            } : {}), {
                i: r.o(function(r) {
                    return l.sortAction(e, t);
                }, t),
                j: r.n(t < l.fixedLeftColumns.length && "zb-stick-side"),
                k: "".concat(e.left, "px"),
                l: "".concat(e.width ? e.width : "100", "px"),
                m: t === l.transColumns.length - 1 ? 1 : "none",
                n: "".concat(e.width ? e.width : "100", "px"),
                o: e.align || "left",
                p: t
            });
        }),
        c: i.border ? "1px solid #e8e8e8" : "",
        d: i.border ? "1px solid #e8e8e8" : ""
    } : {}, {
        e: !i.data.length
    }, (i.data.length, {}), {
        f: r.f(l.transData, function(t, n, o) {
            return {
                a: r.f(l.transColumns, function(c, a, s) {
                    return r.e({
                        a: "operation" === c.type
                    }, "operation" === c.type ? {
                        b: r.f(l.permission(t, c.renders, n), function(i, o, l) {
                            return r.e({
                                a: "custom" === i.type
                            }, "custom" === i.type ? {
                                b: r.t(i.name),
                                c: r.n(i.class || "")
                            } : {
                                d: r.t(i.name),
                                e: r.n(i.class || ""),
                                f: i.type || "primary",
                                g: i.size || "mini"
                            }, {
                                h: o,
                                i: r.o(function(r) {
                                    return e.$emit(i.func, t, n);
                                }, o)
                            });
                        }),
                        c: c.renders.length > 1 ? "8px" : "0"
                    } : "selection" === c.type ? {
                        e: r.o(function(e) {
                            return l.checkboxSelected(e, t);
                        }, a),
                        f: "6252a029-1-" + o + "-" + s,
                        g: r.p({
                            cellData: t,
                            checked: t.checked
                        })
                    } : "img" === c.type ? r.e({
                        i: t[c.name]
                    }, t[c.name] ? {
                        j: r.f(l.imgs(t[c.name]), function(e, i, n) {
                            return {
                                a: r.o(function(r) {
                                    return l.previewImage(e, t[c.name], i);
                                }, i),
                                b: i,
                                c: e
                            };
                        }),
                        k: r.o(function() {}, a)
                    } : {
                        l: r.t(c.emptyString)
                    }) : "index" === c.type ? {
                        n: r.t(n + 1)
                    } : {
                        o: r.t(c.filters ? l.itemFilter(t, c) : l.formatterAction(t, c, n, a))
                    }, {
                        d: "selection" === c.type,
                        h: "img" === c.type,
                        m: "index" === c.type,
                        p: r.s({
                            left: "".concat(c.left, "px"),
                            width: "".concat(c.width ? c.width : "100", "px"),
                            flex: a === l.transColumns.length - 1 ? 1 : "none",
                            minWidth: "".concat(c.width ? c.width : "100", "px"),
                            borderRight: i.border ? "1px solid #e8e8e8" : "",
                            textAlign: c.align || "left"
                        }),
                        q: r.s(l.getCellStyle(t, c, n, a)),
                        r: r.o(function(e) {
                            return l.cellClick(t, n, c);
                        }, a),
                        s: r.n(a < l.fixedLeftColumns.length && "zb-stick-side"),
                        t: a
                    });
                }),
                b: r.n(i.stripe ? n % 2 != 0 ? "odd" : "even" : ""),
                c: r.n(i.highlight && l.isHighlight(t, n) ? "current-row" : ""),
                d: r.o(function(e) {
                    return l.rowClick(t, n);
                }, t.key),
                e: t.key
            };
        }),
        g: i.showSummary
    }, i.showSummary ? {
        h: r.p({
            data: i.data,
            showSummary: i.showSummary,
            fixedLeftColumns: l.fixedLeftColumns,
            transColumns: l.transColumns,
            border: i.border,
            "summary-method": i.summaryMethod,
            sumText: i.sumText
        })
    } : {}, {
        i: r.o(function() {
            return l.scrolltolower && l.scrolltolower.apply(l, arguments);
        }),
        j: o.isLoadMore && !o.completeLoading
    }, (o.isLoadMore && o.completeLoading, {}));
} ], [ "__scopeId", "data-v-6252a029" ] ]);

wx.createComponent(n);